package com.qyer.util.log.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PlatformUtil {
	
	//平台静态变量
	public static final String APPH5="apph5";
	public static final String MOBILE="mobile";
	public static final String WEB="web";
	public static final String APP="app";
	
	public static final String FS="\t";
	
	public static Map<String ,String > pfMaps = new HashMap<String, String>();
	
	static {
		pfMaps.put("http://appview.qyer.com", APPH5);
		pfMaps.put("http://m.qyer.com", "mobile");
	}

	public static List<String> getPlatform(String platform,  String clientId , String os_browser) {
		List<String> ps = new ArrayList<String>();
		StringBuilder sb = new StringBuilder();
		
		sb.append("A").append(FS).append("A").append(FS).append("A").append(FS).append("A");
		ps.add(sb.toString());
		
		if(WEB.equals(platform)){
			sb = new StringBuilder();
			sb.append(platform).append(FS).append("A").append(FS).append("A").append(FS).append("A");
			ps.add(sb.toString());
		}else if (MOBILE.equals(platform)){
			sb = new StringBuilder();
			sb.append("m").append(FS).append("A").append(FS).append("A").append(FS).append("A");
			ps.add(sb.toString());
			if (os_browser!=null && os_browser.toUpperCase().contains("MICROMESSENGER")){
				sb = new StringBuilder();
				sb.append("m").append(FS).append("mm").append(FS).append("A").append(FS).append("A");
			}else{
				sb = new StringBuilder();
				sb.append("m").append(FS).append("m").append(FS).append("A").append(FS).append("A");
			}
			ps.add(sb.toString());
			
		}else if (APPH5.equals(platform)||APP.equals(platform)){
			sb = new StringBuilder();
			sb.append("app").append(FS).append("A").append(FS).append("A").append(FS).append("A");
			ps.add(sb.toString());
			
			if(clientId!=null){
				int len = 0 ; 
				if(clientId.lastIndexOf("_")>-1){
					len=clientId.lastIndexOf("_");
				}else{
					len=clientId.length();
				}
				String channel = clientId.substring(0 , len);
				String device = clientId.substring(len+1);
				
				sb = new StringBuilder();
				sb.append("app").append(FS).append(channel).append(FS).append("A").append(FS).append("A");
				ps.add(sb.toString());
				
				sb = new StringBuilder();
				sb.append("app").append(FS).append(channel).append(FS).append(device).append(FS).append("A");
				ps.add(sb.toString());
			}
		}
		return ps;
	}
}
